import BaseUtil from '@/BaseUtil';
import LightningEffects from '@/LightningEffects';
import SelectUtil from '@/SelectUtil';
import UnitStateUtil from '@/UnitStateUtil';
import EffectCommon from 'code/Core/Common/EffectCommon';
import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 燃烧法力
 **/
export default class BossSpell_BurnMana extends AbilityBase {
    static instance: BossSpell_BurnMana;
    constructor(id: string = 'Mxy0') {
        super(id);
        BossSpell_BurnMana.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {}
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        BossAbilityManagerInstance.text('法力燃烧', source);
        BaseUtil.runLater(1, () => {
            let tar = SelectUtil.getRandomEnemyInRange(source, 1000);
            if (tar == null) {
                source = null;
                return;
            }
            let l = AddLightningEx(LightningEffects.fa_li_ran_shao, true, GetUnitX(source), GetUnitY(source), 20, GetUnitX(tar), GetUnitY(tar), 20);
            EffectCommon.延迟删除闪电(l, 1);
            UnitStateUtil.addMana(tar, -3000);
            UnitStateUtil.addMana(source, 3000);
            DestroyEffect(AddSpecialEffectTarget('Abilities\\Spells\\NightElf\\ManaBurn\\ManaBurnTarget.mdl', tar, 'origin'));
            let fp = UnitCommon.getFullProperty(tar);
            DamageSystemInstance.applyDarkDamage(tar, source, 600 + fp * 3);
        });
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
